package top.goldenyear.porpoise.framework.web.core.filter;

import lombok.extern.slf4j.Slf4j;
import org.noear.solon.annotation.Component;
import org.noear.solon.core.handle.Context;
import org.noear.solon.core.handle.Filter;
import org.noear.solon.core.handle.FilterChain;

/**
 * @author airhead
 */
@Slf4j
@Component(delivered = false, tag = "appApi", index = -1)
public class AppExceptionFilter implements Filter {
  @Override
  public void doFilter(Context ctx, FilterChain chain) {
    try {
      chain.doFilter(ctx);
    } catch (Throwable e) {
      log.error(e.getMessage(), e);
      ctx.status(404);
    }
  }
}
